﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Narau.Common;
using Narau.Required_interfaces;

namespace Narau.WindowsForms
{
    class TreeNode_WF : ReqIntf_TreeNode
    {
        private TreeView m_WF_TreeView;
        private TreeNode m_WF_TreeNode;
        private string strNodeTxt;
        private string strNodeData;
        //private Intf_TreeNodeListener m_iListener;

        

        //--------------
        // Constructor
        //--------------
        public TreeNode_WF(TreeView inTreeView, TreeNode inTreeNode)
        {
            m_WF_TreeView = inTreeView;
            m_WF_TreeNode = inTreeNode;

            m_WF_TreeNode.Tag = this;
        }

        public void OnSelect()
        {
            Listener.OnSelect(LinkedObject);
        }

        private void UpdateString()
        {
            m_WF_TreeNode.Text = strNodeTxt + " - - - " + strNodeData;
        }

        //--------------------------------------------
        // Implementación interfaz: ReqIntf_TreeNode
        //--------------------------------------------
        #region ReqIntf_TreeNode Members

            public ReqIntf_TreeNodeListener Listener { get; set; }
            public Object LinkedObject { get; set; }

            public void SetNameString(string strName)
            {
                strNodeTxt = strName;
                UpdateString();
            }

            public void SetDataString(string strData)
            {
                strNodeData = strData;
                UpdateString();
            }

            public ReqIntf_TreeNode NewChildTreeNode()
            {
                TreeNode new_node;

                m_WF_TreeView.BeginUpdate();
                new_node = m_WF_TreeNode.Nodes.Add("");
                m_WF_TreeView.EndUpdate();

                return new TreeNode_WF(m_WF_TreeView, new_node);
            }

        #endregion        
    }
}
